﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Content/Master.Master" Inherits="System.Web.Mvc.ViewPage<SCS.Core.ViewModels.OrderViewModels>" %>
<%@ Import Namespace="SCS.Core" %>
<%@ Import Namespace="SCS.Core.Models" %>
<%@ Import Namespace="SCS.Core.ViewModels" %>
<%@ Import Namespace="SCS.Core.Controllers" %>
<%@ Import Namespace="SCSService" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Đơn đặt hàng
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
   <script type="text/javascript" src="/ThemeExtends/AdminSkin/js/jquery.flot.js"></script>
    <script type="text/javascript" src="/ThemeExtends/AdminSkin/js/jquery.flot.stack.js"></script>	
    <link rel="stylesheet" type="text/css" href="/Content/smoothness-1.8.13/jquery-ui-1.8.13.custom.css"/>
    <link rel="stylesheet" type="text/css" href="/Content/smoothness-1.8.13/ui.dropdownchecklist.themeroller.css"/>
    <script type="text/javascript" src="/Scripts/jquery-1.6.1.min.js"></script>
    <script type="text/javascript" src="/Scripts/jquery-ui-1.8.13.custom.min.js"></script>
    <script type="text/javascript" src="/Scripts/ui.dropdownchecklist-1.4-min.js"></script>
    <script type="text/javascript" src="/Scripts/ui.dropdownchecklist.js"></script>
  

   
   <!--Popup-->
     <link rel="stylesheet" href="/Content/popup.css" />
    <script type="text/javascript">
        $(document).ready(function () {

            //When you click on a link with class of poplight and the href starts with a #  
            $('a.poplight[href^=#]').click(function () {
                var popID = $(this).attr('rel'); //Get Popup Name 
                var popURL = $(this).attr('href'); //Get Popup href to define size 

                //Pull Query & Variables from href URL 
                var query = popURL.split('?');
                var dim = query[1].split('&');
                var popWidth = dim[0].split('=')[1]; //Gets the first query string value 

                //Fade in the Popup and add close button 
                $('#' + popID).fadeIn().css({ 'width': Number(popWidth) }).prepend('<a href="#" class="close"><img src="/Content/images/popup-closeButton.png" class="btn_close" title="Close Window" alt="Close" /></a>');

                //Define margin for center alignment (vertical + horizontal) - we add 80 to the height/width to accomodate for the padding + border width defined in the css 
                var popMargTop = ($('#' + popID).height() + 80) / 2;
                var popMargLeft = ($('#' + popID).width() + 80) / 2;

                //Apply Margin to Popup 
                $('#' + popID).css({
                    'margin-top': -popMargTop,
                    'margin-left': -popMargLeft
                });

                //Fade in Background 
                $('body').append('<div id="fade"></div>'); //Add the fade layer to bottom of the body tag. 
                $('#facebox_overlay').css({ 'filter': 'alpha(opacity=80)' }).fadeIn(); //Fade in the fade layer  

                return false;
            });


            //Close Popups and Fade Layer 
            $('a.close, #facebox_overlay').live('click', function () { //When clicking on the close or fade layer... 
                $('#facebox_overlay , .popup_block').fadeOut(function () {
                    $('#facebox_overlay, a.close').remove();
                }); //fade them both out 

                return false;
            });


        }); 
    </script>  
   <!--Popup-->

   <script type="text/javascript">
       function getShippment(value) {
           $.ajax({
               type: "POST",
               url: '<%=Url.Action("GetListPupupShipment","HomeMaster")%>' + '/' + value,
               contentType: "application/json; charset=utf-8",
               dataType: "json",
               success: function (result) {
                    
                   //var innertext = result
                   // $('#TemplateTable').val(result);
                   $('#TemplateTable').html(result.toString());
                   var div = $("#TemplateTable");
                   div.html(result);
               }
           });

       }
    </script>

 <script type="text/javascript">
     $(function () {
         $("#StartDate").datepicker();
         $("#EndDate").datepicker();
     });
	</script>

     <% int index = 1;
        string textstatus = "";
         %>
      <% using (Html.BeginForm("ListOrder", "HomeMaster", FormMethod.Post, new { id = "sendFileForm", enctype = "multipart/form-data" }))
   {%>
    <div class="clear"></div>
    <div class="column full">
    <div class="box ">
        
		<h2 class="box-header"></h2>
		<div class="box-content">

                    <div id="grid">	
                     <table class="display"  >
                      <tr>
                                        <td></td>
                                        <td>
                                            
                                        </td>

                                        <td colspan="2" style="text-align: right;">
                                            Ngày bắt đầu <%=Html.TextBoxFor(m=>m.StartDate,new { @class = "form-field datepicker"}) %>
                                            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                            Đến ngày: <%=Html.TextBoxFor(m=>m.EndDate,new { @class = "form-field datepicker"}) %>
                                        </td>
                                        
                                       
                                        <td>
                                            <%
                                                List<SelectListItem> statusSearch = new List<SelectListItem>();
                                                statusSearch.AddRange(new SelectListItem[] {
                                                new SelectListItem{Text="Tất cả",Value=""}, 
                                                new SelectListItem{ Text = "Chưa thanh toán", Value = "0" },
                                                new SelectListItem{ Text = "Đã thanh toán", Value = "1" }
                                                });
                                                %>

                                                <%=Html.DropDownListFor(m => m.StatusSearch, statusSearch, new { @Style = "width: 180px;height: 23px;" })%> 
                                        </td>
                                        <td>
                                            <input type="submit" value="Tìm kiếm" class="button themed"/>
                                        </td>
                                    </tr>
                    </table> 		    						               
				                <table class="display" id="tabledata" >
                                <thead>
					                <tr>
                                        <th>
                                           STT
                                        </th>
                                        
						                <th>
                                            <a href="#" class="<%= HomeMasterController.GetGridThClass(ViewData, "OrderID") %>" 
										                onclick="<%= HomeMasterController.GetGridThOnClick(ViewData, "OrderID")%>">
								               Mã Đơn Hàng</a>
                                        </th>
                                        
                                        <th>
                                            <a href="#" class="<%= HomeMasterController.GetGridThClass(ViewData, "Fullname") %>" 
										                onclick="<%= HomeMasterController.GetGridThOnClick(ViewData, "Fullname")%>">
								                Tên Người Đặt Hàng</a>
                                        </th>
                                        	               
						                <th style="text-align: center;">
							                <a href="#" class="<%= HomeMasterController.GetGridThClass(ViewData, "StartDate") %>" 
										                onclick="<%= HomeMasterController.GetGridThOnClick(ViewData, "StartDate")%>">
								                Ngày Tạo Đơn Hàng</a>
						                </th>    
                                        <th style="text-align: center;">
                                         <a href="#" class="<%= HomeMasterController.GetGridThClass(ViewData, "OrderStatus") %>" 
										                onclick="<%= HomeMasterController.GetGridThOnClick(ViewData, "OrderStatus")%>">
								                Tình Trạng Đơn Hàng</a>
                                        </th>
                                          <th></th>   
                                          <th></th>
                                          <th></th>                                   
					                </tr>
                                                           
                                </thead>
                                <% if (Model.ListCustomer_Order.Count() == 0)
                                   { %>
			                        <tbody>
                                        <tr>
                                            <td colspan="8">
                                               Không tìm thấy đơn hàng
                                            </td>
                                        </tr>
                                    </tbody>
		                        <% } else {  %>
                                <tbody>
					                <% foreach (var item in Model.ListCustomer_Order) { %>
				    
						                <tr>
                                            <td>
								                <%: (index++).ToString() %>
							                </td>						                
							                <td>
								                <%: item.OrderID.ToString().Trim() %>
							                </td>
							
                                            <td>
                                                <%: item.Fullname.ToString().Trim()%>
                                            </td>

                                            <td style="text-align: right;">
                                                <%: item.CreateDate.ToString().Trim()%>
                                            </td>

							               
                                           
                                            <td style="text-align: right; padding-right:10px">
                                               <%
                                                    //bool newStatus=false;
                                                    
                                                    if ((int)item.OrderStatus == 0)
                                                    {
                                                        //newStatus=true;
                                                        textstatus = "Chưa thanh toán";
                                                    }
                                                    else if ((int)item.OrderStatus == 1)
                                                    {
                                                        //newStatus=false;
                                                        textstatus = "Đã thanh toán";
                                                    }
                                                %>
                                                <%=textstatus%>
                                               
                                            </td>
                                            <td>
                                                <%: Html.ActionLink("Chi tiết ", "DetailOrder", new { id = item.OrderID })%>
                                            </td>
                                            <td>
                                               
                                                 <a href="#?w=600" rel="popup_name" class="poplight" onclick="getShippment(<%:item.OrderID %>)">Chi tiết chuyển hàng</a> 
                                                <br />
                                                <div id="popup_name" class="popup_block">                                
                                                        <div id="TemplateTable" ></div>
                                                      
                                                </div>

                                               
                                                
                                            </td>
                                            <td>
                                                 <%
                                                    string returnUrl = Request.Url.ToString();
                                                 %>
                                               <%-- <%: Html.ActionLink("Xóa", "DeleteCustomerOrder", new { id = item.OrderID, returnUrl = returnUrl }, new { onclick = "return confirm('Bạn muốn xóa đơn hàng mã :" + item.OrderID + " ?');" })%>--%>
                                                <span class="button white"><%= Html.ActionLink(" ", "DeleteCustomerOrder", new { id = item.OrderID, returnUrl = returnUrl }, new { @class = "icon_single cancel", style = "color:#cc0000;", onclick = "return confirm('Bạn thực sự muốn xóa?');" })%></span>

                                            </td>
                                            <%--<td>
                                               
                                                <%: Html.ActionLink("Confirm", "ConfirmCustomerOrder", new { id = item.OrderID, returnUrl = returnUrl }, new { onclick = "return confirm('Confirm:" + item.Fullname + " ?');" })%>
                                            </td>--%>
						                </tr>
				    
					                <% } %>
					            </tbody>
                                <% } %>
				                </table>
			                <!-- data -->
                              <%--  <% if (Model.ListCustomer_Order.Count() > 0)
                                   { %>
			                       <% Html.RenderPartial("~/Views/Commont/Paging.ascx"); %>
		                        <% } %>--%>
		                
	                </div>  <!-- grid -->	
                
               
	    </div>
	</div>
    <div class="clear"></div>
   
    </div>    
<% } %>
 
                                              
     <script type="text/javascript">
         function getTemModify() {
             var iframe = document.getElementById("Content_TemplateDetail_html");

             if (document.all || document.getElementById) {
                 document.getElementById('Content_TemplateDetailValueINOUT').value = iframe.contentWindow.document.body.innerHTML;
             }
             else {
                 document.getElementById('Content_TemplateDetailValueINOUT').setAttribute("value", iframe.contentWindow.document.body.innerHTML);
             }

             // document.getElementById("btnSaveTemplate").disabled = true;

         }
</script>                       
</asp:Content>
